<template>
  
  <div class="app-page">
    <!-- <div style="width: 200px;height:100px;color:red;position:absolute;z-index:5555555">
      cfgvdfsdasdasdasd
    </div> -->
    <particles/>
    <indexbg/>
    <div class="main-contaner">
      <el-row>
        <el-col :span="12" :offset="12">
          <h1>消防综合管控平台</h1>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12" :offset="12">一个管理消防信息的可视化大数据平台"。通过它，您可以更加直观看到消防系统的一些数据情况</el-col>
      </el-row>
      <el-row>
        <el-col :span="12" :offset="12">
          <el-form ref="loginForm" :model="formdata" label-width="80px;" class="input_text" :inline="true" :rules="rules">
            <el-form-item label="账---号" prop="username">
              <el-input placeholder="请输入账号" v-model="formdata.username" class="input_text" style="width:290px;">
                
              </el-input>
            </el-form-item>
            <br/>
            <el-form-item label="密---码" prop="password">
              <el-input placeholder="请输入密码" v-model="formdata.password" class="input_text" style="width:290px;">
                
              </el-input>
            </el-form-item>
            <br/>
            <el-form-item label="验证码" prop="code" required>
              <el-input placeholder="请输入验证码" v-model="formdata.code" class="input_text" style="width:130px" >

              </el-input>
            </el-form-item>
            <div style="margin: 3px;display: inline-block;">

            <img src="http://47.105.40.29:8080/gifCode" alt="">
            </div>
            <br/>
            <el-form-item label="" style="margin-left:60px;">
              <el-button style="width:250px;" :loading="logining" @click="submitForm">
                登录
              </el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12" :offset="12">
          <span>
            点击「登录」按钮将视为您同意
          </span>
          <span>
            服务条款
          </span>
        </el-col>
      </el-row>
    </div>
    <foot/>
  </div>
</template>

<script>

import userService from 'services/userService'

export default {
  components: {

  },
  data() {
    return {
      logining: false,
      formdata: {
        username: 'tester',
        password: '123456',
        code: '1111',
        rememberMe: true,
      },
      rules: {
        username: [
          { required: true, message: '不能为空', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '不能为空', trigger: 'blur' }
        ],
      }
    };
  },
  created() {

  },
  methods: {
    submitForm() {
      console.log("111111");
      // this.$router.push('/datapage')
      
      this.$refs["loginForm"].validate(validate =>{
        if (validate) {
          this.logining = true;
          // NProgress.start();
          var loginParams = { code: this.formdata.code, phone: this.formdata.phone };

          // userService.login(loginParams).then(res => {
            let res = {
              code: 1,
              access_token: 'aaaaa'
            }
            console.log(res);
              this.logining = false
              // NProgress.done()
              if (res.code == 1){
                  sessionStorage.setItem('oauth', JSON.stringify(res))
                  this.$store.dispatch('loginName', res)

                  this.$router.push('/datapage')

              }else{
                  this.$message.error(res.msg)
              }
          // }).catch(res => {
          //   this.logining = false
          // })
        }
      })
    }
  }
};
</script>

<style lang="scss">
// @import "./index";

.main-contaner{
  position: relative;
  z-index: 10003;
  margin: 100px;
  .el-row{
    margin: 20px 0px;
  }
  .input_text{
    color: red;
  }
  .el-button{
    color: aliceblue;
    background-color: transparent;
  }
  .el-form-item__content{
    color: red;
  }
  .el-input__inner{
    color: aliceblue;
    background-color: transparent;
  }

}

// .app-page{
//   position: fixd;
//   z-index: 99999 !important;
//   // color:red;
//   // background-color: red;
//   .input_text{
//     color: #FFFFFF;
//     border-radius: .5rem;
//     background-color: transparent;
//   }
// }


</style>